package org.kou.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.kou.bean.ShoppingBean;
import org.kou.servlet.ShoppingLogin;
import org.sen.utils.PublicUtils;

/**
 * Servlet implementation class SaveChat
 * 在用户点击购买之后跳转到支付页面
 */
@WebServlet("/SaveShoppingcar")
public class SaveShoppingcar extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		ShoppingBean admink = PublicUtils.convertFormData2Bean(request, ShoppingBean.class);
		int i = PublicUtils.getInstance(ShoppingLogin.class).savedata(admink);
		if (i > 0) {
			// 保存成功
			response.sendRedirect("../kou/cardemo.jsp支付页面");
		} else {
			// 保存失败
			response.sendRedirect("../kou/shoppingcar.jsp");
		}
	}
}
